#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 100010;
vector<int> G[N]; //邻接表
bool isRoot[N];//记录每个节点是否作为某个集合的根节点
int father[N];
int findFather(int x)
{
    int a = x;
    while(x != father[x])
        x = father[x];
    //路径压缩
    while(a != father[a])
    {
        int z = a;
        a = father[a];
        father[z] = x;
    }
    return x;
}
void Union(int a , int b)
{
    int faA = findFather(a);
    int faB = findFather(b);
    if(faA != faB)
    {
        father[faA] = faB;
    }
}
void init(int n)
{
    for(int i = 1 ; i <= n; ++i)
    {
        father[i] = i;
    }
}
int calBlock(int n)//计算连通数目
{
    int Block = 0;
    for(int i = 1 ; i <= n; ++i)
    {
        isRoot[findFather(i)] = true;
    }
    for(int i = 1 ; i <= n ; ++i)
    {
        Block += isRoot[i];
    }
    return Block;
}
int maxH = 0;
vector<int> temp , Ans;//temp 临时存放DFS的最远节点的结果，Ans保存答案
//DFS函数，u为当前访问的节点编号，Height为当前树高，pre为u的父节点
void DFS(int u , int Height , int pre)
{
    if(Height > maxH)
    {
        temp.clear();
        temp.push_back(u);
        maxH = Height;
    }
    else if(Height == maxH)
    {
        temp.push_back(u);
    }
    for(int i = 0 ; i < G[u].size() ; ++i)
    {
        if(G[u][i] == pre)
            continue;
        DFS(G[u][i] , Height+1 , u);
    }
}
int main()
{
    int a , b  ,n;
    scanf("%d" , &n);
    init(n);//并查集初始化
    for(int i = 1 ; i < n ; ++i)
    {
        scanf("%d%d" , &a , &b);
        G[a].push_back(b);
        G[b].push_back(a);
        Union(a , b); //合并a和b所在的集合
    }
    int Block = calBlock(n); //计算集合数目（很巧妙的计算无向图的连通分量算法）
    if(Block != 1)
        printf("Error: %d components\n" , Block);
    else
    {
        DFS(1 ,1 ,-1);
        Ans = temp;
        DFS(Ans[0] , 1  ,-1);
        for(int i = 0 ; i < temp.size() ; ++i)
        {
            Ans.push_back(temp[i]);
        }
        sort(Ans.begin() , Ans.end());
        printf("%d\n" , Ans[0]);
        for(int i = 1; i < Ans.size() ; ++i)
        {
            if(Ans[i] != Ans[i-1])
            {
                printf("%d\n" , Ans[i]);
            }
        }
    }
    return 0;
}
